<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Struct template pointer_traits</title>
<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
<link rel="up" href="../intrusive/reference.html#doxygen.pointer__traits_8hpp" title="Header &lt;boost/intrusive/pointer_traits.hpp&gt;">
<link rel="prev" href="structboost_1_1intrusive_1_1pointer__rebinder_3_01Ptr_3_01A_00_01An_8_8_8_01_4_00_01U_00_010u_01_4.html" title="Struct template pointer_rebinder&lt;Ptr&lt; A, An... &gt;, U, 0u&gt;">
<link rel="next" href="structboost_1_1intrusive_1_1pointer__traits_3_01T_01_5_01_4.html" title="Struct template pointer_traits&lt;T *&gt;">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td>
<td align="center"><a href="../../../index.html">Home</a></td>
<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="structboost_1_1intrusive_1_1pointer__rebinder_3_01Ptr_3_01A_00_01An_8_8_8_01_4_00_01U_00_010u_01_4.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive/reference.html#doxygen.pointer__traits_8hpp"><img src="../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="structboost_1_1intrusive_1_1pointer__traits_3_01T_01_5_01_4.html"><img src="../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="refentry">
<a name="doxygen.structboost_1_1intrusive_1_1pointer__traits"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Struct template pointer_traits</span></h2>
<p>boost::intrusive::pointer_traits</p>
</div>
<h2 class="refsynopsisdiv-title">Synopsis</h2>
<div class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../intrusive/reference.html#doxygen.pointer__traits_8hpp" title="Header &lt;boost/intrusive/pointer_traits.hpp&gt;">boost/intrusive/pointer_traits.hpp</a>&gt;

</span><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> Ptr<span class="special">&gt;</span> 
<span class="keyword">struct</span> <a class="link" href="structboost_1_1intrusive_1_1pointer__traits.html" title="Struct template pointer_traits">pointer_traits</a> <span class="special">{</span>
  <span class="comment">// <a class="link" href="structboost_1_1intrusive_1_1pointer__traits.html#doxygen.structboost_1_1intrusive_1_1pointer__traitstypes">types</a></span>
  <span class="keyword">typedef</span> <span class="identifier">Ptr</span>              <a class="link" href="structboost_1_1intrusive_1_1pointer__traits.html#doxygen.structboost_1_1intrusive_1_1pointer__traits_1a4feffdd7f212c549c6eda6711d0da0be"><span class="identifier">pointer</span></a><span class="special">;</span>        
  <span class="keyword">typedef</span> <span class="identifier">unspecified_type</span> <a class="link" href="structboost_1_1intrusive_1_1pointer__traits.html#doxygen.structboost_1_1intrusive_1_1pointer__traits_1ab540c424ce7bf0c698188fc5a2d46aad"><span class="identifier">element_type</span></a><span class="special">;</span>   
  <span class="keyword">typedef</span> <span class="identifier">unspecified_type</span> <a class="link" href="structboost_1_1intrusive_1_1pointer__traits.html#doxygen.structboost_1_1intrusive_1_1pointer__traits_1a26be05c89e0291ef2863b07a642ec902"><span class="identifier">difference_type</span></a><span class="special">;</span>
  <span class="keyword">typedef</span> <span class="identifier">unspecified</span>      <a class="link" href="structboost_1_1intrusive_1_1pointer__traits.html#doxygen.structboost_1_1intrusive_1_1pointer__traits_1a1ceab2e8f845e9b9e9dc4fb3f4c4adc9"><span class="identifier">rebind</span></a><span class="special">;</span>         
  <span class="keyword">typedef</span> <span class="identifier">unspecified_type</span> <a class="link" href="structboost_1_1intrusive_1_1pointer__traits.html#doxygen.structboost_1_1intrusive_1_1pointer__traits_1a81d8e517a5daab69683b1c71b50b5d96"><span class="identifier">reference</span></a><span class="special">;</span>      

  <span class="comment">// <a class="link" href="boost_container_header_reference/classboost_1_1container_1_1new__allocator.html#id63-bb">public static functions</a></span>
  <span class="keyword">static</span> <span class="identifier">pointer</span> <a class="link" href="structboost_1_1intrusive_1_1pointer__traits.html#doxygen.structboost_1_1intrusive_1_1pointer__traits_1a9cf3240838196362b3b1372c32640c98"><span class="identifier">pointer_to</span></a><span class="special">(</span><span class="identifier">reference</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> UPtr<span class="special">&gt;</span> 
    <span class="keyword">static</span> <span class="identifier">pointer</span> <a class="link" href="structboost_1_1intrusive_1_1pointer__traits.html#doxygen.structboost_1_1intrusive_1_1pointer__traits_1a8b04b3498c81af58b1d334e1b59a83b5"><span class="identifier">static_cast_from</span></a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">UPtr</span> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> UPtr<span class="special">&gt;</span> 
    <span class="keyword">static</span> <span class="identifier">pointer</span> <a class="link" href="structboost_1_1intrusive_1_1pointer__traits.html#doxygen.structboost_1_1intrusive_1_1pointer__traits_1a349c2ad333f7b801a5ba79d6317b7a06"><span class="identifier">const_cast_from</span></a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">UPtr</span> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> UPtr<span class="special">&gt;</span> 
    <span class="keyword">static</span> <span class="identifier">pointer</span> <a class="link" href="structboost_1_1intrusive_1_1pointer__traits.html#doxygen.structboost_1_1intrusive_1_1pointer__traits_1a46aa0725eec82b8ddfcd889883aa15b6"><span class="identifier">dynamic_cast_from</span></a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">UPtr</span> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
<span class="special">}</span><span class="special">;</span></pre></div>
<div class="refsect1">
<a name="id-1.3.17.42.26.3.4"></a><h2>Description</h2>
<p><a class="link" href="structboost_1_1intrusive_1_1pointer__traits.html" title="Struct template pointer_traits">pointer_traits</a> is the implementation of C++11 std::pointer_traits class with some extensions like castings.</p>
<p><a class="link" href="structboost_1_1intrusive_1_1pointer__traits.html" title="Struct template pointer_traits">pointer_traits</a> supplies a uniform interface to certain attributes of pointer-like types.</p>
<p><span class="bold"><strong>Note</strong></span>: When defining a custom family of pointers or references to be used with BI library, make sure the public static conversion functions accessed through the <code class="computeroutput"><a class="link" href="structboost_1_1intrusive_1_1pointer__traits.html" title="Struct template pointer_traits">pointer_traits</a></code> interface (<code class="computeroutput">*_cast_from</code> and <code class="computeroutput">pointer_to</code>) can properly convert between const and nonconst referred member types <span class="bold"><strong>without the use of implicit constructor calls</strong></span>. It is suggested these conversions be implemented as function templates, where the template argument is the type of the object being converted from. </p>
<div class="refsect2">
<a name="id-1.3.17.42.26.3.4.5"></a><h3>
<a name="doxygen.structboost_1_1intrusive_1_1pointer__traitstypes"></a><code class="computeroutput">pointer_traits</code> 
        public
       types</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<p>
<span class="keyword">typedef</span> <span class="identifier">Ptr</span> <a name="doxygen.structboost_1_1intrusive_1_1pointer__traits_1a4feffdd7f212c549c6eda6711d0da0be"></a><span class="identifier">pointer</span><span class="special">;</span></p>
<p>The pointer type queried by this <a class="link" href="structboost_1_1intrusive_1_1pointer__traits.html" title="Struct template pointer_traits">pointer_traits</a> instantiation </p>
</li>
<li class="listitem">
<p>
<span class="keyword">typedef</span> <span class="identifier">unspecified_type</span> <a name="doxygen.structboost_1_1intrusive_1_1pointer__traits_1ab540c424ce7bf0c698188fc5a2d46aad"></a><span class="identifier">element_type</span><span class="special">;</span></p>
<p>Ptr::element_type if such a type exists; otherwise, T if Ptr is a class template instantiation of the form SomePointer&lt;T, Args&gt;, where Args is zero or more type arguments ; otherwise , the specialization is ill-formed. </p>
</li>
<li class="listitem">
<p>
<span class="keyword">typedef</span> <span class="identifier">unspecified_type</span> <a name="doxygen.structboost_1_1intrusive_1_1pointer__traits_1a26be05c89e0291ef2863b07a642ec902"></a><span class="identifier">difference_type</span><span class="special">;</span></p>
<p>Ptr::difference_type if such a type exists; otherwise, std::ptrdiff_t. </p>
</li>
<li class="listitem">
<p>
<span class="keyword">typedef</span> <span class="identifier">unspecified</span> <a name="doxygen.structboost_1_1intrusive_1_1pointer__traits_1a1ceab2e8f845e9b9e9dc4fb3f4c4adc9"></a><span class="identifier">rebind</span><span class="special">;</span></p>
<p>Ptr::rebind&lt;U&gt; if such a type exists; otherwise, SomePointer&lt;U, Args&gt; if Ptr is a class template instantiation of the form SomePointer&lt;T, Args&gt;, where Args is zero or more type arguments ; otherwise, the instantiation of rebind is ill-formed.</p>
<p>For portable code for C++03 and C++11, </p>
<pre class="programlisting"><span class="keyword">typename</span> <span class="identifier">rebind_pointer</span><span class="special">&lt;</span><span class="identifier">U</span><span class="special">&gt;</span><span class="special">::</span><span class="identifier">type</span></pre>
<p> shall be used instead of rebind<span style="color: red">&lt;underline&gt; to obtain a pointer to U. &lt;/underline&gt;</span></p>
</li>
<li class="listitem">
<p>
<span class="keyword">typedef</span> <span class="identifier">unspecified_type</span> <a name="doxygen.structboost_1_1intrusive_1_1pointer__traits_1a81d8e517a5daab69683b1c71b50b5d96"></a><span class="identifier">reference</span><span class="special">;</span></p>
<p>Ptr::reference if such a type exists (non-standard extension); otherwise, element_type &amp; </p>
</li>
</ol></div>
</div>
<div class="refsect2">
<a name="id-1.3.17.42.26.3.4.6"></a><h3>
<a name="id63-bb"></a><code class="computeroutput">pointer_traits</code> public static functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><span class="keyword">static</span> <span class="identifier">pointer</span> <a name="doxygen.structboost_1_1intrusive_1_1pointer__traits_1a9cf3240838196362b3b1372c32640c98"></a><span class="identifier">pointer_to</span><span class="special">(</span><span class="identifier">reference</span> r<span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
<p><span class="bold"><strong>Remark</strong></span>: If element_type is (possibly cv-qualified) void, r type is unspecified; otherwise, it is element_type &amp;.</p>
<p><span class="bold"><strong>Returns</strong></span>: A dereferenceable pointer to r obtained by calling Ptr::pointer_to(reference). Non-standard extension: If such function does not exist, returns <a class="link" href="structboost_1_1intrusive_1_1pointer__traits.html#doxygen.structboost_1_1intrusive_1_1pointer__traits_1a4feffdd7f212c549c6eda6711d0da0be">pointer(addressof(r))</a>;</p>
<p><span class="bold"><strong>Note</strong></span>: For non-conforming compilers only the existence of a member function called <code class="computeroutput">pointer_to</code> is checked. </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> UPtr<span class="special">&gt;</span> 
  <span class="keyword">static</span> <span class="identifier">pointer</span> <a name="doxygen.structboost_1_1intrusive_1_1pointer__traits_1a8b04b3498c81af58b1d334e1b59a83b5"></a><span class="identifier">static_cast_from</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">UPtr</span> <span class="special">&amp;</span> uptr<span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
<p><span class="bold"><strong>Remark</strong></span>: Non-standard extension.</p>
<p><span class="bold"><strong>Returns</strong></span>: A dereferenceable pointer to r obtained by calling the static template function Ptr::static_cast_from(UPpr/const UPpr &amp;). If such function does not exist, returns pointer_to(static_cast&lt;element_type&amp;&gt;(*uptr))</p>
<p><span class="bold"><strong>Note</strong></span>: For non-conforming compilers only the existence of a member function called <code class="computeroutput">static_cast_from</code> is checked. </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> UPtr<span class="special">&gt;</span> 
  <span class="keyword">static</span> <span class="identifier">pointer</span> <a name="doxygen.structboost_1_1intrusive_1_1pointer__traits_1a349c2ad333f7b801a5ba79d6317b7a06"></a><span class="identifier">const_cast_from</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">UPtr</span> <span class="special">&amp;</span> uptr<span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
<p><span class="bold"><strong>Remark</strong></span>: Non-standard extension.</p>
<p><span class="bold"><strong>Returns</strong></span>: A dereferenceable pointer to r obtained by calling the static template function Ptr::const_cast_from&lt;UPtr&gt;(UPpr/const UPpr &amp;). If such function does not exist, returns pointer_to(const_cast&lt;element_type&amp;&gt;(*uptr))</p>
<p><span class="bold"><strong>Note</strong></span>: For non-conforming compilers only the existence of a member function called <code class="computeroutput">const_cast_from</code> is checked. </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> UPtr<span class="special">&gt;</span> 
  <span class="keyword">static</span> <span class="identifier">pointer</span> <a name="doxygen.structboost_1_1intrusive_1_1pointer__traits_1a46aa0725eec82b8ddfcd889883aa15b6"></a><span class="identifier">dynamic_cast_from</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">UPtr</span> <span class="special">&amp;</span> uptr<span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
<p><span class="bold"><strong>Remark</strong></span>: Non-standard extension.</p>
<p><span class="bold"><strong>Returns</strong></span>: A dereferenceable pointer to r obtained by calling the static template function Ptr::dynamic_cast_from&lt;UPtr&gt;(UPpr/const UPpr &amp;). If such function does not exist, returns pointer_to(<span class="emphasis"><em>dynamic_cast&lt;element_type</em></span>&gt;(&amp;*uptr))</p>
<p><span class="bold"><strong>Note</strong></span>: For non-conforming compilers only the existence of a member function called <code class="computeroutput">dynamic_cast_from</code> is checked. </p>
</li>
</ol></div>
</div>
</div>
</div>
<div class="copyright-footer">Copyright © 2005 Olaf Krzikalla<br>Copyright © 2006-2015 Ion Gaztanaga<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="structboost_1_1intrusive_1_1pointer__rebinder_3_01Ptr_3_01A_00_01An_8_8_8_01_4_00_01U_00_010u_01_4.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive/reference.html#doxygen.pointer__traits_8hpp"><img src="../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="structboost_1_1intrusive_1_1pointer__traits_3_01T_01_5_01_4.html"><img src="../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
